<meta title="提现管理">
<div class="p">
    <div class="p-b">
        <form class="form-inline m-b-wrapper-xs pull-left" id="form" s="form"
              s-form="{action:function(){$page.node.val(1); $userWithdrawsGrid.refresh()}}"
        >
            <input autocomplete="off" type="text" class="form-control input-sm" placeholder="用户手机号" name="userPhone" />
            提现时间：<input autocomplete="off" type="text" class="form-control input-sm" s="datetimepicker" name="createStartDate"  placeholder="开始时间" />
            - <input autocomplete="off" type="text" class="form-control input-sm" s="datetimepicker" name="createEndDate"  placeholder="结束时间" />
            <select class="form-control input-sm" s="select"
                    s-build="S.get('/api/enum/valuesMap/core.enums.UserWithdrawStatus')"
                    name="status">
                <option value="">选择状态</option>
            </select>
            <input autocomplete="off" type="hidden" name="page" id="page" value="1"/>
            <input autocomplete="off" type="submit" class="btn btn-default btn-sm" value="查找"/>
        </form>
        <input type="button" class="btn pull-right btn-default btn-sm" s-click="exportXsl()" value="导出"/>
    </div>
    <table
            id="userWithdrawsGrid"
            s='datac,nda'
            s-data="Smart.cleanJsonRef(S.get('/api/user-withdraw/search', $form.node.serialize()))"
            class="table table-stripped table-bordered">
        <tr>
            <th>用户手机号</th>
            <th>提现金额</th>
            <th>支付宝账号</th>
            <th>收款姓名</th>
            <th>提现时间</th>
            <th>转账类型</th>
            <th>支付宝交易号</th>
            <th>转账时间</th>
            <th class="text-center">备注</th>
            <th class="text-center">状态</th>
            <th class="text-right">操作</th>
        </tr>
        <tbody s="loop" s-data-filter="'results'">
        <tr s-loop-role="empty">
            <td colspan="11" class="alert alert-warning">
                暂无数据
            </td>
        </tr>
        <tr s-loop-role="row" s="row,datac">
            <td name="userPhone"></td>
            <td name="money"></td>
            <td name="payeeAccount"></td>
            <td name="payeeName"></td>
            <td name="createTime"></td>
            <td name="fundTransferTypeTitle"></td>
            <td name="alipayOrderId"></td>
            <td name="payDate"></td>
            <td name="remark"></td>
            <td class="text-center" s="tpl">
                <label class="label
                            {%
                                switch(this.status) {
                                    case 'WAIT_VERIFY':
                                        out.print('label-warning'); break;
                                    case 'WAIT_TRANSFER':
                                    case 'ON_TRANSFER':
                                        out.print('label-info'); break;
                                    case 'VERIFY_FAIL':
                                    case 'TRANSFER_FAIL':
                                        out.print('label-danger'); break;
                                    case 'TRANSFER_SUCCESS':
                                        out.print('label-success'); break;
                                    default:
                                        out.print('label-default');break;
                                }
                            %}
                        ">{%=this.statusTitle%}</label>
            </td>
            <td s="tpl" class="text-right">
                {%if(this.status == 'WAIT_VERIFY'
                || this.status == 'TRANSFER_FAIL'
                || this.status == 'WAIT_TRANSFER') {%}
                <input autocomplete="off" type="button" s-click="verify(this)" class="btn btn-xs btn-warning btn-outline" value="审核"/>
                {%}%}
                {%if(this.status == 'WAIT_TRANSFER' || this.status == 'RETRY_TRANSFER' || this.status == 'TRANSFER_FAIL') {%}
                <input autocomplete="off" type="button" s-click="manualTransfer(this)" class="btn btn-xs btn-danger btn-outline" value="人工转账"/>
                <input autocomplete="off" type="button" s-click="transfer(this)" class="btn btn-xs btn-danger btn-outline" value="系统转账"/>
                {%}%}
            </td>
        </tr>
        </tbody>
        <tfoot>
        <tr>
            <td colspan="11" class="text-right">
                <ul s="pagination" id="sellerPagination"
                    s-pagination="{action:function(){$page.node.val(this); $userWithdrawsGrid.refresh()}}"
                    class="pagination pagination-sm">
                </ul>
                共有<span name="total"></span>个数据
            </td>
        </tr>
        </tfoot>
    </table>
</div>
<script type="text/javascript">
	function verify($s) {
		S.popupOpen("/userWithdraw/userWithdraw-verify.html", {userWithdraw: $s.parent().data()}).done(function(rs) {
			rs && $userWithdrawsGrid.refresh()
		})
	}

	function transfer($s) {
		var data = $s.parent().data();
		S.confirm("确认立即转账吗").done(function() {
			S.post("/api/user-withdraw/fund-transfer/" + data.id).done(function(rs) {
				if(rs.success) {
					S.toast("转账成功")
					$userWithdrawsGrid.refresh()
				} else {
					S.alert("转账失败，原因为：" + rs.errMsg)
				}
			})
		})
	}

	function manualTransfer($s) {
		S.popupOpen("/userWithdraw/userWithdraw-manual-transfer.html", {userWithdraw: $s.parent().data()}).done(function(rs) {
			rs && $userWithdrawsGrid.refresh()
		})
	}

	function exportXsl() {
		S.popupOpen('/export-num.html').done(function (maxCount) {
			if (maxCount) {
				window.open('/api/user-withdraw/export?' + $form.node.serialize() + '&maxCount=' + maxCount)
			}
		})
	}

</script>